{extend name="base"/}
{block name="title"}用户管理-编辑{/block}
{block name="main"}
<div class="x-body">
    <form class="layui-form">
        {volist name="users" id="vo"}
        <input type="hidden" id="staff_id" value="{$vo.staff_id}"/>
        <div class="layui-form-item">
            <label for="L_email" class="layui-form-label">
                用户名称</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="login_name" value="{$vo.login_name}">
            </div>
            <div class="layui-form-mid layui-word-aux">必填</div>
        </div>
        <div class="layui-form-item">
            <label for="L_username" class="layui-form-label">
                性别
            </label>

            <div class="layui-inline">
                <div class="layui-input-inline" id="checkRadio">
                    <input type="radio" name="sex" value="0" title="男" {if condition ='$vo.sex eq 0'}checked {/if}>
                    <input type="radio" name="sex" value="1" title="女" {if condition ='$vo.sex eq 1'}checked {/if}>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_city" class="layui-form-label">
                职员角色
            </label>
            <div class="layui-input-inline">
                <input type="text" id="staff_name" name="staff_name" value="{$vo.staff_name}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label for="L_sign" class="layui-form-label">
                备注信息
            </label>
            <div class="layui-input-block">
                        <textarea placeholder="随便写些什么刷下存在感" name="sign" autocomplete="off"
                                id="message"  value="" class="layui-textarea" style="height: 80px;">{$vo.message}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_sign" class="layui-form-label">
            </label>
            <button class="layui-btn" id="btn" key="set-mine" lay-filter="save" lay-submit>提交</button>
        </div>
        {/volist}
    </form>
</div>
{/block}
{block name="script"}
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form()
            ,layer = layui.layer;

        //监听提交
        form.on('submit(save)', function(data){
//            layer.alert("提交成功", {icon: 6},function () {
//                // 获得frame索引
//                var index = parent.layer.getFrameIndex(window.name);
//                //关闭当前frame
//                parent.layer.close(index);
//            });
            return false;
        });

    });

    $(function(){
        $("#btn").click(function(){
            var params = {};
            params.staff_id = $("#staff_id").val();
            params.login_name = $.trim($("#login_name").val());
            params.staff_name = $.trim($("#staff_name").val());
            params.sex = $('#checkRadio input[name="sex"]:checked ').val();
            params.message= $.trim($("#message").val());
            console.debug(params);
            if(params.login_name==''){
                layer.msg('用户名不能为空',{time:1000});
                $("#login_name").focus();
                return false;
            }

            $.post("{:url('admin/Users/userEdit')}",params,function(data){
                console.dir(data);
                if(data>0){
                    layer.msg('编辑成功！',{time:1000});
                    setTimeout('location.href="{:url(\'admin/Users/user\')}"',1000);
                }else{
                    layer.msg('编辑失败！',{time:1000});
                }
            });
        });
    })
</script>
<script>
    var _hmt = _hmt || [];
    (function() {
        var hm = document.createElement("script");
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>
{/block}
